#ifndef CHATWIDGET_H
#define CHATWIDGET_H

#include <QWidget>
#include <QString>

#include "message.h"

namespace Ui {
class ChatWidget;
}

class ChatWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ChatWidget(QWidget *parent = nullptr);
    ~ChatWidget();


    QString toId() const;
    void setToId(const QString &newToId);

    Message::Type chatType() const;
    void setChatType(Message::Type newChatType);

    void sendOnlineMessage(QString);

    void setChatTitle(QString);

protected:
    // 事件过滤器，用于回车发送
    bool eventFilter(QObject *, QEvent *);

signals:
    void signal_chatSendData(QString);
    void signal_chatSendMessage(Message);

public slots:
    void slot_chatReceiveMessage(Message);

private slots:

    void on_pushButton_send_clicked();

private:
    Ui::ChatWidget *ui;

    QString m_toId;
    Message::Type m_chatType;

    void addMessageItem(Message);
};

#endif // CHATWIDGET_H
